package com.hoopchina.ui.main;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

/**
 * ResizeLayout
 * 变化size的Layout
 * 
 * @author Neusoft
 *
 */
public class ResizeLayout extends LinearLayout {
    private OnResizeListener mListener;

    /**
     * interface OnResizeListener for View size change
     */
    public interface OnResizeListener {
	/**
	 * @param w
	 * @param h
	 * @param oldw
	 * @param oldh
	 */
	void OnResize(int w, int h, int oldw, int oldh);
    }

    /**
     * 设置监听器
     */
    public void setOnResizeListener(OnResizeListener l) {
	mListener = l;
    }

    /**
     * 构造器
     */
    public ResizeLayout(Context context, AttributeSet attrs) {

	super(context, attrs);
    }

    /**
     * 监听大小的改变
     */
    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
	super.onSizeChanged(w, h, oldw, oldh);
	if (mListener != null) {
	    mListener.OnResize(w, h, oldw, oldh);
	}
    }
}